/*
 * @Author: error: git config user.name && git config user.email & please set dead value or install git
 * @Date: 2021-12-10 09:36:46
 * @LastEditors: ipk518 18163976442@163.com
 * @LastEditTime: 2023-08-15 16:16:31
 * @FilePath: /etws-sxkV12/Middlewares/convert/convert.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include "myLog.h"
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>

using namespace std;  
INITIALIZE_EASYLOGGINGPP  

#define SBUF_SIZE 512


// 0.[A]：断言(Assert)
// 1.[E]：错误(Error)
// 2.[W]：警告(Warn)
// 3.[I]：信息(Info)
// 4.[D]：调试(Debug)
// 5.[V]：详细(Verbose)
bool my_logInit(const char* confFile)
{  
    // Load configuration from file
    el::Configurations conf(confFile);
    // Reconfigure single logger
    el::Loggers::reconfigureLogger("default", conf);
    // Actually reconfigure all loggers instead
    el::Loggers::reconfigureAllLoggers(conf);
    // Now all the loggers will use configuration from file
  // 防止Fatal级别日志中断程序
    el::Loggers::addFlag(el::LoggingFlag::DisableApplicationAbortOnFatalLog);
    LOG(INFO) << "my easyloging is success";  
    return 1;  
}

//ERROR
void qerror(const char* fmt, ...)
{
    va_list ap; 
    char buf[SBUF_SIZE] = {0}; 
    va_start(ap, fmt); 
    vsnprintf(buf, SBUF_SIZE, fmt, ap); //用于格式化字符串并将字符串放入buf中
    va_end(ap);

    LOG(ERROR) << buf; 

}

//WARNING
void qwarn(const char* fmt, ...)
{
    va_list ap; 
    char buf[SBUF_SIZE] = {0}; 
    va_start(ap, fmt); 
    vsnprintf(buf, SBUF_SIZE, fmt, ap); //用于格式化字符串并将字符串放入buf中
    va_end(ap);
    LOG(WARNING) << buf; 
}
//DEBUG
void debug(const char *file, const char *func,
        const long line, const char *format, ...)
{
    va_list ap; 
    char buf[SBUF_SIZE] = {0}; 
    va_start(ap, format); 
    vsnprintf(buf, SBUF_SIZE, format, ap); //用于格式化字符串并将字符串放入buf中
    va_end(ap);
    
    LOG(DEBUG) << file << ":" << func << ":" <<line << ":" << buf; 
}

//INFO
void qinfo(const char* fmt, ...)
{
    va_list ap; 
    char buf[SBUF_SIZE] = {0}; 
    va_start(ap, fmt); 
    vsnprintf(buf, SBUF_SIZE, fmt, ap); //用于格式化字符串并将字符串放入buf中
    va_end(ap);

    LOG(INFO) << buf; 

}
//TRACE
void qtrace(const char* fmt, ...)
{
    va_list ap; 
    char buf[SBUF_SIZE] = {0}; 
    va_start(ap, fmt); 
    vsnprintf(buf, SBUF_SIZE, fmt, ap); //用于格式化字符串并将字符串放入buf中
    va_end(ap);

    LOG(TRACE) << buf; 

}

